﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebShopDAL;
using KlauserswagModel;

namespace ProjektarbeteKlauserSwag
{
    public partial class ConfirmOrder : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ShowOrderDetails();
            RemoveSessions();
        }

        private void RemoveSessions()
        {
            try
            {
                Session.Remove("Cart");
                Session.Remove("OrderInformation");
            }
            catch (Exception)
            {
            }
        }

        private void ShowOrderDetails()
        {
            try
            {
                var orderInformation = Session["OrderInformation"] as OrderInformation;
                if (orderInformation != null)
                {
                    var user = orderInformation.CurrentUser;
                    ListBoxShowUser.Items.Add(new ListItem(orderInformation.TotalSum));
                    ListBoxShowUser.Items.Add(new ListItem(user.Firstname + " " + user.Lastname));
                    ListBoxShowUser.Items.Add(new ListItem(user.Address));
                    ListBoxShowUser.Items.Add(new ListItem(user.Zip));
                    ListBoxShowUser.Items.Add(new ListItem(user.City));
                    ListBoxShowUser.Items.Add(new ListItem(user.Email));
                    ListBoxShowUser.Items.Add(new ListItem(user.Phone));
                }
            }
            catch (Exception)
            {

            }
        }
    }
}